from mysql_util import MysqlUtil
# username = "aaa"
#
# sql = "SELECT * FROM user_table  WHERE username = '%s'" % (username)  # 根据用户名查找user表中记录
# db = MysqlUtil()  # 实例化数据库操作类

# result = db.fetchone(sql)  # 获取一条记录
# # db_password = result['password']
# # print(db_password)
# # print(result)

db = MysqlUtil()
sql = 'SELECT COUNT(*) AS num_products FROM product_temp'
result = db.fetchone(sql)
if result:
    num_products = result['num_products']
else:
    num_products = 0  # 或者你可以抛出一个异常，表示没有找到任何记录

# 输出商品数量
print(f"商品数量: {num_products}")
